﻿using Aurora.AI.Abstractions;
using Aurora.AI.Abstractions.Chats;
using Aurora.AI.Abstractions.Embeddings;
using Aurora.AI.Abstractions.Images;
using Aurora.AI.SparkDesk.Chats;
using Aurora.AI.SparkDesk.Embeddings;
using Aurora.AI.SparkDesk.Helpers;
using Aurora.AI.SparkDesk.Images;
using Microsoft.Extensions.DependencyInjection;

namespace Aurora.AI.SparkDesk.Extensions;

public static class SparkDeskServiceCollectionExtensions
{
    public static IServiceCollection AddSparkDeskService(this IServiceCollection services)
    {
        //添加 Ollama 平台支持
        AuroraAIGlobal.PlatformNames.Add(SparkDeskPlatformOptions.PlatformName, SparkDeskPlatformOptions.PlatformCode);

        // 添加平台支持模型列表
        var modelNames = SparkDeskModelHelper.ModeInfoDict.Values.Select(x => x.Name).Order().ToList();
        AuroraAIGlobal.ModelNames.Add(SparkDeskPlatformOptions.PlatformCode, modelNames);

        services.AddKeyedSingleton<IAuroraAIChatCompletionsService, SparkDeskChatCompletionsService>(SparkDeskPlatformOptions.PlatformCode);

        services.AddKeyedSingleton<IAuroraAIImageService, SparkDeskImageService>(SparkDeskPlatformOptions.PlatformCode);

        services.AddKeyedSingleton<IAuroraAITextEmbeddingService, SparkDeskTextEmbeddingService>(SparkDeskPlatformOptions.PlatformCode);

        return services;
    }
}